package com.zyl.log;
import org.apache.log4j.Logger;
/**
 * @version v1.0
 * @ProjectName: env_gather
 * @Package: com.zyl.log
 * @ClassName: LogImpl
 * @Description TODO(日志接口的实现类)
 * 用于封装Log4j日志模块的门面
 * @Author 翟玉龙
 * @Date 2024/10/22-11:40
 */
public class LogImpl implements Log {
    // 获取正在输出日志的日志对象
    private final Logger logger = Logger.getRootLogger();

    private static volatile Log instance;

    // 私有化构造器
    private LogImpl() {

    }

    // 懒汉模式
    public static Log getInstance() {
        if (instance == null) {
            synchronized (LogImpl.class) {
                if (instance == null) {
                    instance = new LogImpl();
                }
            }
        }
        return instance;
    }

    @Override
    public void error(String message) {
        logger.error(message);
    }

    @Override
    public void warn(String message) {
        logger.warn(message);
    }

    @Override
    public void info(String message) {
        logger.info(message);
    }

    @Override
    public void debug(String message) {
        logger.debug(message);
    }
}
